
/**
 *@描述：权限管理
 *@作者：顾云飞
 *@创建时间：2023/1/17
 *@最后修改时间：2023/1/18
 */
 import { EllipsisOutlined, PlusOutlined } from '@ant-design/icons';
 import type { ActionType, ProColumns } from '@ant-design/pro-components';
 import { ProTable } from '@ant-design/pro-components';
 import { Space, Tag,Table} from 'antd';
 import { useRef } from 'react';
 import request from 'umi-request';
 
 type UserItem = {
   url: string;
   id: string;
   number: number;
   title: string;
   state: string;
   comments: number;
   created_at: string;
   updated_at: string;
   closed_at?: string;
 };
 
 const columns: ProColumns<UserItem>[] = [
 //   {
 //     dataIndex: 'index',
 //     valueType: 'indexBorder',
 //     width: 48,
 //   },
   {
     title: 'ID',
     dataIndex: 'id',
     search: false
   },
   {
     title: '权限名称',
     dataIndex: 'name',
   },
   {
     title: '权限分组',
     dataIndex: 'group',
   },
   {
    title: '描述',
    dataIndex: 'description',
    },
    {
      title: '接口标识',
      dataIndex: 'apiTag',
    },
    {
     title: '操作',
     valueType: 'option',
     key: 'option',
     render: (text, record, _, action) => [
        <a href={record.url} target="_blank" rel="noopener noreferrer" key="view">
        角色授权
      </a>,
       <a
        key="editable"
        href={`/dashboard/system/user/details/${record.id}`}
      >
        修改
      </a>,
       <a href={record.url} target="_blank" rel="noopener noreferrer" key="view">
         删除
       </a>
     ],
   },
 ];
 
 const UserList = () => {
   const actionRef = useRef<ActionType>();
   return (
     <ProTable<UserItem>
       columns={columns}
       rowSelection={{
         selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT]
       }}
       actionRef={actionRef}
       cardBordered
       request={async (params = {}, sort, filter) => {
         console.log(sort, filter);
         return request<{
           data: UserItem[];
         }>('https://proapi.azurewebsites.net/github/issues', {
           params,
         });
       }}
       editable={{
         type: 'multiple',
       }}
       columnsState={{
         persistenceKey: 'pro-table-singe-demos',
         persistenceType: 'localStorage',
         onChange(value) {
           console.log('value: ', value);
         },
       }}
       rowKey="id"
       search={{
         labelWidth: 'auto',
       }}
       options={{
         setting: {
           listsHeight: 400,
         },
       }}
       form={{
         // 由于配置了 transform，提交的参与与定义的不同这里需要转化一下
         syncToUrl: (values, type) => {
           if (type === 'get') {
             return {
               ...values,
               created_at: [values.startTime, values.endTime],
             };
           }
           return values;
         },
       }}
       tableAlertOptionRender={() => {
         return (
           <Space size={16}>
             <a>批量删除</a>
             <a>批量禁用</a>
             <a>审核通过</a>
           </Space>
         );
       }}
       pagination={{
         pageSize: 5,
         onChange: (page) => console.log(page),
       }}
       dateFormatter="string"
       headerTitle="批量操作"
     />
   );
 };
 export default UserList